/**
 *  fileName:new.js
 *  time:2023/4/13
 *  todo:new 实现了什么 函数、类转换成对象
 */

let Student = function (name) {
  this.name = name
}
let xiaoming = new Student('xiaoming')
console.log(`xiaoming ==> `, xiaoming)
console.log(`xiaoming.name ==> `, xiaoming.name)


function createObj (fn,...args) {
  let obj = Object.create(fn.prototype)
  fn.apply(obj,args)
  return obj
}

let Student2 = function (name) {
  this.name = name
}
let xiaohong = createObj(Student2,'xiaohong')
console.log(`xiaohong ==> `, xiaohong)
console.log(`xiaohong.name ==> `, xiaohong.name)
